package com.gzs.learn.payment.pay.action;

import com.gzs.learn.inf.BaseResponseDto;
import com.gzs.learn.payment.inf.dto.UnifyPaymentResponse;
import com.gzs.learn.payment.pay.ContextBase;
import com.gzs.learn.payment.pay.PaymentContext;
import com.gzs.learn.payment.pay.PaymentTypeEnum;
import com.gzs.learn.payment.pay.context.PaymentRequestContext;
import com.gzs.learn.payment.service.IPaymentService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class PaymentAction extends BaseAction {
    private final IPaymentService paymentService;

    @Override
    public BaseResponseDto<?> executeAction(PaymentContext<ContextBase> context) {
        PaymentRequestContext contextObject = (PaymentRequestContext) context.getContextObject();
        PaymentTypeEnum paymentTypeEnum = context.getPaymentTypeEnum();
        BaseResponseDto<UnifyPaymentResponse> responseDto = paymentService.unifyPayment(contextObject.getPaymentRequest());
        switch (paymentTypeEnum) {
            case ALIPAY:
                break;
            case WECHAT:
                break;
            case UNIONPAY:
                break;
            default:
                break;
        }
        return responseDto;
    }

}
